<template>
	<view>
		<view class="topbg">
			<!-- <image src="https://ayh.wissun.net/static/ayh/icon33.png" /> -->
			<image src="https://ayh.wissun.net/static/ayh/750.png?1" mode=""/>
		</view>
		<view class="stitdv">
			<view class="stit">
				<view class="titletip">明一扫码领好礼  扫码三部曲</view>
				<view class="threeicon">
					<view class="thk">
						<image src="https://ayh.wissun.net/static/ayh/r1.png" mode="widthFix"></image>
						<view class="ree">打开奶粉罐</view>    
					</view>
					<view class="jtou">
						<image src="https://ayh.wissun.net/static/ayh/r4.png" mode="widthFix"></image>
					</view>
					<view class="thk">
						<image src="https://ayh.wissun.net/static/ayh/r3.png" mode="widthFix"></image>
						<view class="ree">撕开铝膜</view>
					</view>
					<view class="jtou">
						<image src="https://ayh.wissun.net/static/ayh/r4.png" mode="widthFix"></image>
					</view>
					<view class="thk">
						<image src="https://ayh.wissun.net/static/ayh/r2.png" mode="widthFix"></image>
						<view class="ree">扫描二维码</view>
					</view>
				</view>
				<view class="sqrode" @click="saoyisao">
					<image src="https://ayh.wissun.net/static/ayh/16797160621059.png?1"></image>
				</view>
			</view>
		</view>
	
		<view class="ruledv">
			<view class="rulesm">
				<text>【规则说明】</text>   
				<text>1、开罐扫内码首听必中一等奖，续购开罐扫内码6听必中一等奖1个，其它5听每听随机中其它奖项1个。</text>    
				<text class="lef24">一等奖:+119元得本品1罐。</text>
				<text class="lef24">二等奖: 88元红包。</text>
				<text class="lef24">三等奖:18.8元红包。</text>
				<text class="lef24">四等奖:8.8元红包。</text>
				<text class="lef24">五等奖:1.88元红包。</text>
				<text>2、美优然产品需在购买区域范围内扫码才能享受到活动权益。</text>
				<text>3、每个顾客手机号每月限扫码8次参与活动。</text>
				<!-- <text>5、明一积分是明一会员的虚拟权益，不可转赠或转移至其他账号。</text>
				<text>6、积分按照扫码获取时间进行有效期计算，兑换积分产品并进行退换无法重置积分有效期。</text>
				<text>7、明一会员账号进行注销，对应的积分随即清零且无法恢复。</text>
				<text>8、获取的积分将在次年的12月31日24时过期。</text>
				<text>例:2025年内获得的积分将在2026年12月31日24时过期。</text> -->
			</view>
		</view>
	</view>

</template>

<script>
	export default {
		data() {
			return {
				city:"",
				province:"",
				nation:""
			}
		},
		onShow() {
			this.getAddress()
		},
		methods: {
			saoyisao(){
				var that=this;
				var city=that.city
				var province=that.province
				var nation=that.nation
				//that.getAddress()
				if(that.city == ""){
				   //return
				}
				uni.scanCode({
					success: (res) => {
						console.log(res)
						if(res.errMsg=='scanCode:ok'){
							var data={}
							var tt=res.result.split("=");
							if(tt.length == 1){
								uni.showToast({ title:"无效码",icon:"none"})
								return
							}
							var trace_code=tt[1];
							data.trace_code=trace_code;
							data.city=city;
							data.province=province;
							data.nation=nation;
							data.user_id=uni.getStorageSync('user_id')
							data.openid=uni.getStorageSync('openid')
							that.request('/api/code/code_of_trace_code', data,"post").then(data => {
								uni.redirectTo({
									url:"/pages/index/integral?integral="+data.info.integral+"&prize_id="+data.info.prize_id+"&prize_integral="+data.info.prize_integral+"&sncode="+data.info.sncode+"&record_id="+data.info.record_id+"&product_code="+data.info.product_code
								})
							})
						}
					},
					fail(res) {
						console.log(res)
					}
				})
			},
			getAddress: function() {
				var n = this;
				uni.getLocation({
					type: 'wgs84',
					success: function(e) {
						var d={}
						d.latitude=e.latitude
						d.longitude=e.longitude
						uni.setStorageSync('latitude', e.latitude)
						uni.setStorageSync('longitude', e.longitude)
						n.request('/api/code/get_city', d,"post").then(ret => {
							n.city=ret.info.result.address_component.district
							n.province=ret.info.result.address_component.province
							n.nation=ret.info.result.address_component.nation
						})
					},
					fail: (res) => {
						console.log(res)
						if(res.errno==103){
							uni.showModal({
							  title: '提示',
							  content:"请手动开启定位，点击顶部三点-设置开启"
							})
						}else if(res.errno==104){
							uni.navigateTo({
							  url: '/pages/login/login',
							})
						}
						else{
							if(res.errCode == 2){
								uni.showModal({
									title: '提示',
									showCancel:false,
									content:"请先开启定位"
								  })
							}else if(res.errCode == 1){
							  uni.showModal({
								  title: '提示',
								  showCancel:false,
								  content:"请关闭WIFI并开启定位"
								})
							}else if(res.errCode == -1){
							  uni.showModal({
								  title: '提示',
								  showCancel:false,
								  content:"请开启手机定位"
								})
							}
							else{
								uni.showModal({
									title:"提示",
									showCancel:false,
									content: "错误码:"+JSON.stringify(res),
								})
							}
						}
					}
				});
			 },
		}
	}
</script>

<style>
.topbg{ height: 171px; width: 100%;}
.topbg image{width: 100%;height: 100%;}
.thk{
    width: 81px;
    height: 50px;
    margin: 15px;
    font-size: 12px;
    text-align: center;
}
.lef24{text-indent: 24px;}
.thk image{ width: 100%;height: 100%;}
.stit{
    width: calc(100% - 10%);
    height: 215px;
    margin: 0 auto;
    background: url("https://pf.wissun.net/public/static/saoma/icon5.png");
    background-size: 100% 100%;
    position: relative;
    top: -52px;
}
.threeicon{display: flex;justify-content: space-between;}
.stitdv{ width: 100%; height: 100%;}
.titletip{
    height: 52px;
    line-height: 52px;
    text-align: center;
    color: #FFDCA7;
    font-size: 17px;
}
.thk{
   
    margin: 15px;
    font-size: 12px;
    text-align: center;
}
.thk image{  width: 100%;  height: 100%;}
.sqrode{  width: 100px; height: 94px;  margin: 20px auto;margin-top: 40px;}
.sqrode image{
    width: 100%;
    height: 100%;
}
.ruledv{
    width: 86%;
    margin: 30px auto;
    background: #F7DDB9;
    border: 1px dashed #F49F21;
    border-radius: 20px;
}
.rulesm{
    color: #4F391A;
    font-size: 13px;
    display: flex;
    flex-direction: column;
    padding: 10px;
}
.jtou{
    height: 8px;
    width: 44px;
    margin-top: 30px;
}
.jtou image{width: 100%;height: 100%;}
page{
    /* background: url("https://ayh.wissun.net/static/ayh/icon241.png"); */
    background-color: #84DCD7;
    background-size: cover;
    background-position: 180px 0px 0px 0px;
    /* background-color: #1652aa; */
}
.ree{ color: #BE8128;}
.blc{ color: #412C1E;}
.zan-dialog__mask {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 10;
    background: rgba(0, 0, 0, 0);
    background: rgba(0, 0, 0, 0.4);
    display: none;
 }
.zan-dialog__container {
    position: fixed;
    top: 30%;
    width: 650rpx;
    height: 350rpx;
    margin-left: 50rpx;
    background: #f8f8f8;
    transform: translateY(300%);
    transition: all 0.4s ease;
    z-index: 12;
    border-radius: 20rpx;
    box-shadow: 0px 3px 3px 2px gainsboro;
}
.zan-dialog--show .zan-dialog__container {
transform: translateY(0);
}
.zan-dialog--show .zan-dialog__mask {
display: block;
}
</style>
